% This is a basic script to load a dataset and then run one of the algs

%dataname = 'corridor_2000_2011_02/2000_pri_2011_02.xls'; % Name of dataset to load
dataname = 'corridor_2000_2011_02/test.xls'; % Name of dataset to load
worksheet = 'Speed';

dataset = loaddata(dataname,worksheet);

minFA = [];
avgPerf = [];
for k=1:4
    for m=1:8
        % GREEDY - uncomment this section to run GREEDY
        %FA = place_then_sched(dataset, k, m);
        
        % RANDOM - uncomment this section to run RANDOM
        %FA = random_alg(dataset, k, m);

        % GAPS - uncomment this section to run GAPS
        sensors = gaps_alg(dataset(2:end,:), k, m, Inf);
        for i=1:k
            FA(k) = get_quality(dataset(2:end,:), sensors(1,:), Inf);
        end
        % end GAPS

        % find the avg and min FA
        totalFA = 0;
        minFA(m,k) = FA(1);
        for n=1:k
            totalFA = totalFA + FA(n);
            if(FA(n) < minFA(m,k))
                minFA(m,k) = FA(n);
            end
        end
        avgPerf(m,k) = totalFA ./ k;
    end
end

close all

figure('Name','Average Value of F(A)'); 
plot(avgPerf,'LineWidth',2);
get(gca);
set(gca,'fontsize',32);
title('Average Value of F(A)','fontsize',24,'fontweight','b'); 
xlabel('Nodes to add to Network (m)','fontsize',20,'fontweight','b');
ylabel('Average F(At)','fontsize',20,'fontweight','b');
legend('k=1','k=2','k=3','k=4','Location','Southeast');

figure('Name','Minimum Value of F(A)'); 
plot(minFA,'LineWidth',2);
get(gca);
set(gca,'fontsize',32);
title('Minimum Value of F(A)','fontsize',24,'fontweight','b'); 
xlabel('Nodes to add to Network (m)','fontsize',20,'fontweight','b');
ylabel('Min F(At)','fontsize',20,'fontweight','b');
legend('k=1','k=2','k=3','k=4','Location','Southeast');
